<%--
  Created by IntelliJ IDEA.
  User: DELL
  Date: 2024/9/26
  Time: 上午 11:29
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>

<div id="text" align="center" style="text-align: center">
    <h1>查询学生信息</h1>

    <br>
    <table align="center" width="40%" style="text-align: center" cellspacing="0" cellpadding="0" border="1" id="tabel">
        <thead>
        <tr>
            <td>编号</td>
            <td>姓名</td>
            <td>地址</td>
            <td>性别</td>
        </tr>
        <tr>
            <td></td>
        </tr>
        </thead>
    </table>
    <br>
    <input type="button" value="查询" id="select">
</div>
<br>
<h1 align="center">新增学生信息</h1>
<div id="add" style="text-align: center" align="center">
    <form action="/StudentServlet?opr=add" method="post">
        <table align="center" style="text-align: center;height: 10px" border="1" cellpadding="0" cellspacing="0" width="30%">
            <tr>
                <td>姓名</td>
                <td>
                    <input type="text" name="name">
                </td>
            </tr>
            <tr>
                <td>地址</td>
                <td>
                    <input type="text" name="address">
                </td>
            </tr>
            <tr>
                <td>性别</td>
                <td>
                    <input type="text" name="sex">
                </td>
            </tr>

            <tr>
                <td colspan="2">
                    <input type="submit" value="提交" id="addIsSuccess">
                    <input type="reset" value="清空">
                </td>
            </tr>
        </table>
    </form>

</div>

<h1 align="center">修改学生信息</h1>
<div id="update" style="text-align: center" align="center">
    <form action="/StudentServlet?opr=update" method="post">
        <table align="center" style="text-align: center;height: 10px" border="1" cellpadding="0" cellspacing="0" width="30%">

            <tr>
                <td>id</td>
                <td>
                    <input type="text" name="updateid">
                </td>
            </tr>

            <tr>
                <td>姓名</td>
                <td>
                    <input type="text" name="updatename">
                </td>
            </tr>
            <tr>
                <td>地址</td>
                <td>
                    <input type="text" name="updateaddress">
                </td>
            </tr>
            <tr>
                <td>性别</td>
                <td>
                    <input type="text" name="updatesex">
                </td>
            </tr>

            <tr>
                <td colspan="2">
                    <input type="submit" value="提交" id="updateIsSuccess">
                    <input type="reset" value="清空">
                </td>
            </tr>
        </table>
    </form>

</div>


<br><br>
<h1 align="center">删除学生信息</h1>
<div id="delete" style="text-align: center" align="center">
    <form action="/StudentServlet?opr=delete" method="post">
        <table align="center" style="text-align: center;height: 10px" border="1" cellpadding="0" cellspacing="0" width="30%">
            <tr>
                <td>id</td>
                <td>
                    <input type="text" name="deleteid">
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <input type="submit" value="提交" id="deleteIsSuccess">
                    <input type="reset" value="清空">
                </td>
            </tr>
        </table>
    </form>

</div>

</body>
<script src="js/jquery(1).js"></script>
<script>
    $("#select").click(function (){
        $.ajax({
            url:"/Servlet",
            type:"post",
            dataType:"json",
            success:function (data){
                for (let i = 0; i < data.length; i++) {
                    var $tr=("<tr><td>"+data[i].id+"</td><td>"+data[i].name+"</td><td>"+data[i].age+"</td><td>"+data[i].gender+"</td><td>"+data[i].major+"</td></tr>");
                    $("#tabel").append($tr);
                }
            }
        })
    })
</script>
</html>
